#!/usr/bin/python
# -*-coding:UTF-8 -*-

# ========================
# @Time  : 2021/3/2
# @Author: Sunny
# ========================

"""
进程不可以共享全局变量，所有的资源都是独立的
进程之间资源是独立的
"""
from multiprocessing import Process
import time

n = 100


def work1():
    global n
    for i in range(500000):
        n += 1
    print('work1执行完毕：', n)


def work2():
    global n
    for i in range(500):
        n += 1
    print('work2执行完毕：', n)


if __name__ == '__main__':
    p1 = Process(target=work1, )
    p2 = Process(target=work2, )

    p1.start()
    p2.start()

    p1.join()
    p2.join()

    print('n的值为', n)
